export default function (url, method, headers, body) {
  return new Promise((resolve, reject) => {
    if (headers === undefined) {
      headers = {}
    }
    if (body === undefined) {
      body = {}
    }
    fetch(url, {
      method: method,
      headers: headers,
      body: body
    })
      .then(resp => resp.json())
      .then(json => resolve(json))
      .catch(e => reject(e))
  })
}